from multiprocessing import Process
import concurrent.futures
import time

start = time.perf_counter()


def do_something(seconds):
    print(f'Sleeping {seconds} second(s)...')
    time.sleep(seconds)
    return (f'Done sleeping...{seconds}')


# do_something(1)
# do_something(1)

if __name__ == '__main__':
    # processes = []
    # for _ in range(10):
    #     p = Process(target=do_something, args=[1])
    #     p.start()
    #     processes.append(p)
    
    # for p in processes:
        # p.join()
    with concurrent.futures.ProcessPoolExecutor() as executor:
        print(executor._max_workers)
        secs = [5, 4, 3, 2, 1]
        results = executor.map(do_something, secs)
        for result in results:
            print(result)

    finish = time.perf_counter()
    print(f'Finished in {round(finish-start, 2)} second(s)')
